<template>
	<view class="page">
		<view class="flex benben-position-layout flex flex-wrap align-center feedback_flex_0"
			:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx'}">
			<view class='flex flex-wrap align-center justify-between flex-sub feedback_fd0_0'>
				<view class='flex flex-wrap align-center feedback_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
					data-url="1">
					<text class='fu-iconfont2  feedback_fd0_0_c0_c0'>&#xE794;</text>
				</view>
				<text class='feedback_fd0_0_c1'>我要反馈</text>
				<view class='flex flex-wrap align-center feedback_fd0_0_c2'>
					
				</view>
			</view>
		</view>
		<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
		<view class="loading_css" v-if="isShow">
			<u-loading size="36" color="#FC5B03"></u-loading>
			<view>加载中</view>
		</view>
		<template v-else>
			<!---flex布局flex布局开始-->
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout feedback_flex_2">
				<text class='feedback_fd2_0'>
					<text style="color: #EF2E28;">*</text>
					<text>问题描述</text>
				</text>
				<view class='flex flex-wrap feedback_fd2_1'>
					<textarea class='flex feedback_input_fd2_1' confirm-type="done" :placeholder="'问题描述的越详细，有助于我们更快的解决问题'"
						:maxlength="200" placeholder-style="color:rgba(191, 191, 191, 1);font-size:26rpx" v-model="body" />
					<text class="feedback_num">{{body.length}}/200</text>
			
				</view>
				<view class="picture">照片</view>
				<!-- <benben-images-upload ref="benbenImagesUploadfd2_2" :img-list.sync="thumb" :img-ids.sync="thumbId"
					:is-show-tips='true' :maxlength="6">
					<template v-slot="{ num, maxlength, isShow, imgList }">
						<view class="flex flex-wrap align-stretch flex feedback_fd2_2">
			
							<view v-for="(image, index) in imgList" :key="index"
								class='flex position-relative feedback_fd2_20'>
								<text class='fu-iconfont2 position-absolute feedback_fd2_200'
									@tap.stop="$refs.benbenImagesUploadfd2_2.delImage(index)">&#xE8E7;</text>
								<image class='feedback_fd2_201' mode="aspectFill"
									@tap.stop="$refs.benbenImagesUploadfd2_2.previewImage(index)" :src='image'></image>
							</view>
			
							<image class='feedback_fd2_21' @tap.stop="$refs.benbenImagesUploadfd2_2.manyChooseImage()"
								v-if="isShow" mode="aspectFill" :src='"https://app.ezsdcsm.com/images/59.png"'></image>
							<text class='image_upload_tips feedback_fd2_22'>请上传应用截图，最多上传{{maxlength}}张</text>
						</view>
					</template>
				</benben-images-upload> -->
				
				<view class="flex flex-wrap align-stretch flex feedback_fd2_2">
							
					<view v-for="(image, index) in imgList" :key="index"
						class='flex position-relative feedback_fd2_20'>
						<text @tap.stop="delImg(index)" class='fu-iconfont2 position-absolute feedback_fd2_200'
							>&#xE8E7;</text>
						<image @tap.stop="previewImage(index)" class='feedback_fd2_201' mode="aspectFill"
							 :src='image'></image>
					</view>
							
					<image @tap.stop="uploadImg" v-if="imgList.length < 6" class='feedback_fd2_21' mode="aspectFill" :src='STATIC_URL+"286.png"'></image>
					<text class='image_upload_tips feedback_fd2_22'>请上传应用截图，最多上传6张</text>
				</view>
			</view>
			<!---flex布局flex布局结束-->
			<!---flex布局flex布局开始-->
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout feedback_flex_3">
				<view class='feedback_fd3_0'>联系方式</view>
				<view class="phone">
					<view class="phone_le">联系电话</view>
					<view class="phone_ri">{{user.tel}}</view>
				</view>
			</view>
			<!---flex布局flex布局结束-->
			<view class="flex align-center justify-between feedback_flex_4">
				<!-- <view class='feedback_fd4_1' @tap.stop="handleJumpDiy" data-type="navigateTo" :data-url="`/pages/my/historicalFeedback/historicalFeedback`">反馈记录</view> -->
				<view class='feedback_fd4_0' @tap.stop="getsubmit()">提交</view>
			
			</view>
			<view :style="{height: '138rpx'}"></view>
		</template>
		
	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'
	export default {
		components: {},

		data() {
			return {
				"feedback_id": "1",
				"dataList": {
					"contact_status": "",
					"thumb_status": "",
					"qq_status": "",
					"email_status": "",
					"is_must_qq": "",
					"is_must_email": "",
					"is_must_phone": "",
					"types": []
				},
				"user": {},
				"body": "",
				"thumb": [],
				"contact": "",
				"thumbId": "",
				"is_submit": false,
				"isShow": false,
				"imgList": [],
				"maxImg": 6
			};
		},
		computed: {

		},
		watch: {},
		onLoad(options) {
			
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {
			// this.getgetUser();
			this.getPhone();
		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//获取个人信息
			async getgetUser() {
				//请求方法
				//数据验证
			
				let userData = await this.$api.get(global.apiUrls.getUser_info, {
					
				});
				this.isShow = false;
				if (userData.data.code != 1) {
					this.$message.info(userData.data.info);
					return
				}
				let userinfo = userData.data;
				this.user = userinfo.data;
			},
			getPhone() {
				this.user = global.userInfo;
				console.log(this.user)
			},
			// 图片上传
			uploadImg() {
				let _this = this;
				uni.chooseImage({
					count: _this.maxImg,
					sourceType: ['album', 'camera'],
					success: (chooseImageRes) => {
						const tempFilePaths = chooseImageRes.tempFilePaths;
						uni.showLoading({
							title: '上传中'
						})
						for(let i = 0; i < tempFilePaths.length; i++) {
							uni.uploadFile({
								url: global.BASE_URL + global.apiUrls.postUpload, //仅为示例，非真实的接口地址
								filePath: tempFilePaths[i],
								name: 'image',
								formData: {
									image: 'image',
									type: 0,
									source: 0,
									// user_id: 3,
									user_id: global.userInfo.user_id
								},
								success: (uploadFileRes) => {
									uni.hideLoading();
									let result = JSON.parse(uploadFileRes.data);
									console.log(result);
									if (result.code == 1) {
										// _this.user.photo = result.data.photo;
										_this.imgList.push(result.data.data.file_url);
										_this.maxImg = 6 - this.imgList.length;
									} else {
										_this.$message.info(result.data.info);
									}
								},
								fail: (err) => {
									console.log(err);
									uni.hideLoading();
									_this.$message.info('图片上传失败，请重试');
								}
							});
						}
						
					}
				});
			},
			// 预览图片
			previewImage(index) {
				let _this = this;
				uni.previewImage({
					current: index,
					urls: _this.imgList
				})
			},
			delImg(index) {
				this.imgList.splice(index, 1);
				this.maxImg = 6 - this.imgList.length;
			},
			//提交意见反馈
			async getsubmit() {
				if (this.is_submit) return;
				if (!this.body) {
					this.$message.info('请输入问题描述');
					return;
				}
				this.is_submit = true;
				let gniData = await this.$api.post(global.apiUrls.postFeed, {
					content: this.body,
					image: this.imgList.length > 0 ? this.imgList.join('|') : ''
				});
				if (gniData.data.code != 1) {
					this.is_submit = false;
					this.$message.info(gniData.data.info);
					return
				}
				let gniinfo = gniData.data;
				this.$message.info(gniData.data.info);
				setTimeout(() => {
					this.is_submit = false;
					uni.navigateBack();
				}, 800)
			}
		}
	};
</script>
<style lang="scss" scoped>
	.phone {
		display: flex;
		align-items: center;
		justify-content: space-between;
		.phone_le {
			font-size: 26rpx;
			color: #111111;
		}
		.phone_ri {
			font-weight: bold;
			font-size: 26rpx;
			color: #111111;
		}
	}
	.feedback_num {
		font-weight: 500;
		font-size: 26rpx;
		color: rgba(23,19,19,0.4);
		position: absolute;
		right: 20rpx;
		bottom: 20rpx;
	}
	.picture {
		font-weight: 500;
		font-size: 28rpx;
		color: #171313;
		margin: 40rpx 0 20rpx;
	}
	.feedback_fd4_0 {
		background: #1A66FA;
		width: 702rpx;
		border-radius: 16rpx;
		font-size: 30rpx;
		font-weight: bold;
		color: #fff;
		margin: 0rpx 24rpx 0rpx 24rpx;
		height: 96rpx;
		line-height: 96rpx;
		text-align: center;
	}
	.feedback_fd4_1 {
		border: 1px solid #1593FF;
		width: 220rpx;
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		font-size: 32rpx;
		color: #1593FF;
		margin: 0rpx 32rpx 0rpx 32rpx;
		height: 88rpx;
		line-height: 88rpx;
		text-align: center;
	}

	.feedback_flex_4 {
		width: 750rpx;
		height: 120rpx;
		overflow: hidden;
		position: fixed;
		z-index: 10;
		bottom: calc(0rpx + var(--window-bottom));
		display: flex;
		justify-content: center;
		background: #fff;
	}

	.feedback_fd3_0 {
		font-weight: bold;
		font-size: 30rpx;
		color: #111111;
		margin: 0rpx 0rpx 32rpx 0rpx;
	}

	.feedback_fd3_1 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #333;
		margin: 0rpx 0rpx 24rpx 0rpx;
	}

	.feedback_flex_3 {
		background: #fff;
		margin: 0rpx 24rpx 0rpx 24rpx;
		border-radius: 16rpx;
		padding: 24rpx 20rpx;
	}

	.feedback_fd2_0 {
		font-weight: 500;
		font-size: 28rpx;
		color: #111111;
		margin: 32rpx 0rpx 0rpx 0rpx;
	}

	.feedback_fd2_1 {
		background: #F7F7F7;
		border-radius: 8rpx;
		margin-top: 16rpx;
		font-size: 26rpx;
		position: relative;
	}

	.feedback_input_fd2_1 {
		padding: 20rpx 20rpx 60rpx 20rpx;
		width: 100%;
		height: 240rpx;
		font-size: 26rpx;
		font-weight: 400;
		color: #333;
	}

	.feedback_fd2_2 {
		padding: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 0rpx 32rpx 0rpx;
	}

	.feedback_fd2_20 {
		margin: 0rpx 24rpx 24rpx 0rpx;
	}

	.feedback_fd2_200 {
		top: 0rpx;
		right: 0rpx;
		z-index: 10;
		color: #ff5536;
	}

	.feedback_fd2_201 {
		width: 160rpx;
		height: 160rpx;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
	}

	.feedback_fd2_21 {
		width: 160rpx;
		height: 160rpx;
		margin: 0rpx 24rpx 24rpx 0rpx;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
	}

	.feedback_fd2_22 {
		font-size: 24rpx;
		color: #BFBFBF;
		font-weight: 400;
		width: 100%;
		line-height: 33rpx;
	}

	.feedback_flex_2 {
		background: #fff;
		padding: 0rpx 32rpx 0rpx 32rpx;
		margin: 20rpx 24rpx;
		border-radius: 16rpx;
	}

	.feedback_fd1_0 {
		font-size: 32rpx;
		font-weight: 500;
		color: #1A1A1A;
		line-height: 45rpx;
		margin: 32rpx 32rpx 24rpx 32rpx;
	}

	::v-deep .feedback_fd1_1 {
		padding: 0rpx 16rpx 0rpx 16rpx;
	}

	.feedback_fd1_1_c0 {
		background: #2C8FFF;
		background-size: 100% !important;
		// height: 64rpx;
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		// width: 206rpx;
		margin: 0rpx 16rpx 24rpx 16rpx;
		padding: 16rpx;
	}

	.feedback_fd1_1_c0_c0 {
		font-size: 28rpx;
		font-weight: 400;
		color: #fff;
		line-height: 40rpx;
	}

	.feedback_fd1_1_c1 {
		background: rgba(246, 247, 249, 1);
		background-size: 100% !important;
		// height: 64rpx;
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		// width: 206rpx;
		margin: 0rpx 16rpx 24rpx 16rpx;
		padding: 16rpx;
	}

	.feedback_fd1_1_c1_c0 {
		font-size: 28rpx;
		font-weight: 400;
		color: rgba(153, 153, 153, 1);
		line-height: 62rpx;
	}

	.feedback_fd1_2 {
		background: rgba(248, 248, 248, 1);
		background-size: 100% !important;
		height: 20rpx;
		background-size: 100% auto !important;
		margin: 8rpx 0rpx 0rpx 0rpx;
	}

	.feedback_flex_1 {
		background: #fff;
		background-size: 100% !important;
	}

	.feedback_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
		height: 88rpx;
	}

	.feedback_fd0_0_c0 {
		width: 135rpx;
		height: 45rpx;
	}

	.feedback_fd0_0_c0_c0 {
		font-size: 32rpx;
		font-weight: 500;
		color: #333;
		line-height: 36rpx;
	}

	.feedback_fd0_0_c1 {
		font-size: 32rpx;
		font-weight: bold;
		color: #111111;
	}

	.feedback_fd0_0_c2 {
		width: 135rpx;
		height: 45rpx;
	}

	.feedback_fd0_0_c2_c0 {
		line-height: 45rpx;
		font-size: 32rpx;
		font-weight: 500;
		color: #333333;
	}

	.feedback_flex_0 {
		border-bottom: 1px solid #eee;
		background: #fff;
		background-size: 100% !important;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.page {
		min-height: calc(100vh - var(--window-bottom));
		background: #f6f7fb;
		background-size: 100% auto !important;
	}
</style>
